package com.jiayou.Tank;

import com.jiayou.Map.Body;
import com.jiayou.tools.Constclass;
import com.jiayou.tools.TheGameLoading;

import java.awt.*;
import java.util.List;

public class Tank1 extends Model {
    public boolean up =false,down=false,left=false,right=false;
    public int sw = Constclass.UP;  //坦克的党项
    private Image image;
    private Image i_up = TheGameLoading.getImage("player/player_up.png");
    private Image i_down = TheGameLoading.getImage("player/player_down.png");
    private Image i_right = TheGameLoading.getImage("player/player_right.png");
    private Image i_left = TheGameLoading.getImage("player/player_left.png");
    public Tank1(int x, int y, int width, int heigh, int speed,Image image) {
        super(x, y, width, heigh, speed);
        this.image = image;
    }

    private void move() {
            if (left && (!right && !up && !down)  && x>=10) {
                image = i_left;
                x -= speed;
                sw = Constclass.LEFT;

//                can_down = true;
//                can_right = true;
//                can_up = true;
            }


            if (right && (!left && !up && !down)  && x<=Constclass.WEIGHT-40) {
                image = i_right;
                x += speed;
                sw = Constclass.RIGHT;

//                can_down = true;
//                can_left = true;
//                can_up = true;
            }


            if (up && (!right && !left && !down)  && y>=35) {
                image = i_up;
                y -= speed;
                sw = Constclass.UP;

//                can_down = true;
//                can_right = true;
//                can_left = true;
            }


            if (down && (!right && !up && !left)  && y<=Constclass.HEIGHT-40) {
                image = i_down;
                y += speed;
                sw = Constclass.DOWN;

//                can_left = true;
//                can_right = true;
//                can_up = true;
            }

    }
    public void draw(Graphics graphics){
        Color color = graphics.getColor();
        graphics.setColor(Color.white);
        graphics.setColor(color);
        graphics.drawImage(image,x,y,width,heigh,null);
        move();
    }

    @Override
    public void draw(Graphics graphics, List<Body> list,Tank1 tank1) {

    }


}
